package com.sxj.corejava.code09_集合.set;

import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author 石小俊
 * @date 2025年02月19日
 */
public class Test05_TreeSet {

    public static void main(String[] args) {
        // 对于字符串，按照字典顺序进行排序
        Set<String> names = new TreeSet<>(Arrays.asList("tom", "alex", "jack", "admin", "lucy", "alice"));
        System.out.println(names);

        // 对于数值型,按照数值大小进行排序
        Set<Integer> numbers = new TreeSet<>(Arrays.asList(6, 9, 12, 8, 5, 15, 3, 1, 7));
        System.out.println(numbers);

        // 字典顺序
        Set<String> set = new TreeSet<>(Arrays.asList("6", "12", "1", "21", "2", "15", "24", "8", "9"));
        System.out.println(set);

    }

}
